package com.huangdada.hfweather.controller;

import com.huangdada.hfweather.service.OssService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @Description: 七牛云控制层
 * @PROJECT_NAME: hf-weather
 * @CLASS_NAME:
 * @Author: huanglibin
 * @Date: 2020-04-02 21:19
 * @Version: 1.0
 */
@RestController
@RequestMapping("/qiniu")
public class QiniuController {
    @Autowired
    private OssService ossService;
    @PostMapping("/upload")
    public String upload(MultipartFile file) throws IOException{
        return ossService.uploadFile(file.getInputStream(),file.getOriginalFilename());
    }
    @PostMapping("/download")
    public String download(String fileName) throws IOException{
        return ossService.downLoadFile(fileName);
    }

}

